package com.sds.log;

import java.util.Arrays;


public class ConsoleLog implements Log {
	
	private String prefix;
	private String postfix;
	private StringBuffer sb = new StringBuffer();
	
	ConsoleLog(String prefix, String postfix) {
		this.prefix = prefix;
		this.postfix = postfix;
	}
	ConsoleLog(String prefix) {
		this.prefix = prefix;
		this.postfix = "";
	}
	
	public void debug() {
		out(null);
	}

	public void debug(Object o) {
		if (o instanceof Object[]) {
			out(Arrays.toString((Object[])o));
		}
		else if (o instanceof byte[]) {
			out(Arrays.toString((byte[])o));
		}
		else {
			out(o);
		}
	}
	
	
	private void out(Object o) {
		sb.setLength(0);
		
		sb.append(prefix);
		if (o != null) {
			sb.append(o);
		}
		sb.append(postfix);
		
		System.out.println(sb.toString());
	}
}
